package org.sky.feign;

import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @Auther: 赵明明
 * @Date: 2018/10/23 13:48
 * @Description:
 */
@RestController
public class FeignTest {


    @Autowired
    private FeignTestInInterface feignTestInInterface;


    @Autowired
    private RestTemplate restTemplate;


    @RequestMapping("/select/{code}")
    public Object test(@PathVariable("code") String code) {
        Trace trace = this.feignTestInInterface.selectTrace(code);
        return trace;
    }


    @GetMapping("test/{code}")
    private Object test2(@PathVariable("code") String code) {
        Trace trace = this.restTemplate.getForEntity("http://platform/selectTrace/" + code, Trace.class).getBody();
        return trace;
    }

}

@Data
class Trace {
    private String name;

    private String num;
}
